<?php

namespace App\Repositories\Eloquent\Admin;

use App\Repositories\Eloquent\BaseModel;
use EasySwoole\ORM\AbstractModel;


class MemberOnlineModel extends AbstractModel
{
    use BaseModel;
    protected $tableName = 'k_user_online';
    protected $connectionName = 'wr';
    protected $autoTimeStamp = true;
    protected $createTime = 'add_time';
    protected $updateTime = 'update_time';



    public function getList(array $where = [],$pageNum = PAGE_SIZE){

        $where['a.deleted'] = 0;
        $where['a.status'] = 1;
        $data = $this->create()
            ->alias('k')
            ->field(['k.id','k.address','a.id as mid','a.openid','a.type','a.status','b.name','b.head_url','b.is_vip','b.expiration_time','k.ip','k.active_time','k.add_time','k.login_key'])
            ->join('k_user a','a.id = k.id_user','left')
            ->join('k_user_info b','a.id = b.id_user','left')
            ->where($where)
            ->order('k.active_time','desc')
            ->_page($pageNum);
        return $data;
    }

}